package com.pro.springbootshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pro.springbootshop.entity.AfterSales;
import com.pro.springbootshop.entity.Wares;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AfterSalesMapper extends BaseMapper<AfterSales> {
    @Select("select * from after_sales limit #{pageNo},#{limit}")
    @Results(
            {
                    @Result(column = "after_sales_id",property = "afterSalesId"),
                    @Result(column = "buyer_id",property = "buyerId"),
                    @Result(column = "wares_id",property = "waresId"),
                    @Result(column = "after_sales_title",property = "afterSalesTitle"),
                    @Result(column = "after_sales_detail",property = "afterSalesDetail"),
                    @Result(column = "after_sales_pictures",property = "afterSalesPictures"),
                    @Result(column = "after_sales_state",property = "afterSalesState"),
                    @Result(column = "wares_id",property = "wares",javaType = Wares.class,
                            one=@One(select = "com.pro.springbootshop.mapper.WaresMapper.selectById")
                    )
            }
    )
    List<AfterSales> getAllAfterSales(int pageNo,int limit);
    @Select("select * from after_sales where buyer_id=#{buyerId} limit #{pageNo},#{limit}")
    @Results(
            {
                    @Result(column = "after_sales_id",property = "afterSalesId"),
                    @Result(column = "buyer_id",property = "buyerId"),
                    @Result(column = "wares_id",property = "waresId"),
                    @Result(column = "after_sales_title",property = "afterSalesTitle"),
                    @Result(column = "after_sales_detail",property = "afterSalesDetail"),
                    @Result(column = "after_sales_pictures",property = "afterSalesPictures"),
                    @Result(column = "after_sales_state",property = "afterSalesState"),
                    @Result(column = "wares_id",property = "wares",javaType = Wares.class,
                            one=@One(select = "com.pro.springbootshop.mapper.WaresMapper.selectById")
                    )
            }
    )
    List<AfterSales> buyerGetAllAfterSales(int pageNo,int limit,String buyerId);
    @Select("select * from after_sales where buyer_id=#{buyerId}")
    @Results(
            {
                    @Result(column = "after_sales_id",property = "afterSalesId"),
                    @Result(column = "buyer_id",property = "buyerId"),
                    @Result(column = "wares_id",property = "waresId"),
                    @Result(column = "after_sales_title",property = "afterSalesTitle"),
                    @Result(column = "after_sales_detail",property = "afterSalesDetail"),
                    @Result(column = "after_sales_pictures",property = "afterSalesPictures"),
                    @Result(column = "after_sales_state",property = "afterSalesState"),
                    @Result(column = "wares_id",property = "wares",javaType = Wares.class,
                            one=@One(select = "com.pro.springbootshop.mapper.WaresMapper.selectById")
                    )
            }
    )
    List<AfterSales> buyerGetAllAfterSalesCounts(String buyerId);
}
